package com.linglingC.mapper;


import com.linglingC.pojo.PropertyItem;
import com.linglingC.pojo.PropertyItemNameId;
import org.apache.ibatis.annotations.*;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

@Mapper
public interface PropertyItemMapper {

    @Select("select * from propertyitem")
    ArrayList<PropertyItem> findAll();

    List<PropertyItem> selectP(PropertyItem PropertyItem);

    @Options(useGeneratedKeys = true,keyProperty = "ID")
    @Insert("INSERT INTO propertyitem ( name, price, cycle) " +
            "values (#{name},#{price},#{cycle})")
    void addPropertyItem(PropertyItem propertyItem);

    @Delete("delete  from propertyitem where ID= #{ID}")
    void deleteOnePropertyItem(Integer ID);

    @Update("update propertyitem set name=#{name},price=#{price},cycle=#{cycle} where ID=#{ID}")
    void editPropertyItem(PropertyItem propertyItem);


    @Select("select  ID,name from propertyitem")
    List<PropertyItemNameId> findNameId();

    @Select("select cycle from propertyitem where ID=#{ID}")
    String findCycleByID(int ID);

    @Select("select price from propertyitem where  ID=#{ID}")
    BigDecimal findPriceByID(int item);
}
